package p270jp.pxv.android.activity;

import android.content.ComponentCallbacks;
import android.os.Bundle;
import androidx.compose.p026ui.platform.C0536v1;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.BackStackRecord;
import com.google.android.material.appbar.MaterialToolbar;
import java.io.Serializable;
import java.util.Objects;
import p014ae.AbstractActivityC0071e4;
import p014ae.View$OnClickListenerC0050b;
import p018ai.PixivSettings;
import p047bg.C1124a;
import p064c6.Preconditions;
import p134ei.AnalyticsScreenName;
import p134ei.PixivAnalytics;
import p165fo.Subscribe;
import p189gn.AbstractC3435a;
import p189gn.AbstractC3446l;
import p216hn.Lambda;
import p216hn.Reflection;
import p241im.UserProfileService;
import p258jd.SingleFlatMap;
import p270jp.pxv.android.R;
import p270jp.pxv.android.commonObjects.model.WorkType;
import p270jp.pxv.android.event.SelectWorkTypeEvent;
import p270jp.pxv.android.model.PixivProfile;
import p270jp.pxv.android.response.PixivResponse;
import p314lg.ActivityUserWorkWithoutProfileBinding;
import p320lm.UserProfileRepository;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p370ni.InfoType;
import p467rd.subscribers;
import p491sd.C6034a;
import p547uh.UserWorkFragment;
import p579vo.Qualifier;
import p593wc.Single;
import p603wm.AbstractC6949c;
import p603wm.Unit;
import p645yc.AndroidSchedulers;
import p665z6.C7463r;
import p671zc.CompositeDisposable;
import p671zc.Disposable;

/* compiled from: UserWorkWithoutProfileActivity.kt */
/* renamed from: jp.pxv.android.activity.UserWorkWithoutProfileActivity */
/* loaded from: classes2.dex */
public final class UserWorkWithoutProfileActivity extends AbstractActivityC0071e4 {

    /* renamed from: h0 */
    public static final /* synthetic */ int f18725h0;

    /* renamed from: b0 */
    public ActivityUserWorkWithoutProfileBinding f18726b0;

    /* renamed from: c0 */
    public WorkType f18727c0;

    /* renamed from: d0 */
    public long f18728d0;

    /* renamed from: e0 */
    public final AbstractC6949c f18729e0 = Preconditions.m9802P(1, new C4142c(this, null, null));

    /* renamed from: f0 */
    public final AbstractC6949c f18730f0 = Preconditions.m9802P(1, new C4143d(this, null, null));

    /* renamed from: g0 */
    public final CompositeDisposable f18731g0 = new CompositeDisposable();

    /* compiled from: UserWorkWithoutProfileActivity.kt */
    /* renamed from: jp.pxv.android.activity.UserWorkWithoutProfileActivity$a */
    /* loaded from: classes2.dex */
    public static final class C4140a extends Lambda implements AbstractC3446l<Throwable, Unit> {
        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4140a() {
            super(1);
            UserWorkWithoutProfileActivity.this = r1;
        }

        @Override // p189gn.AbstractC3446l
        public Unit invoke(Throwable th) {
            Throwable th2 = th;
            MutabilityOwnership.m3745m(th2, "throwable");
            UserWorkWithoutProfileActivity userWorkWithoutProfileActivity = UserWorkWithoutProfileActivity.this;
            int i = UserWorkWithoutProfileActivity.f18725h0;
            Objects.requireNonNull(userWorkWithoutProfileActivity);
            Timber.f23100a.mo3514p(th2);
            ActivityUserWorkWithoutProfileBinding e2Var = userWorkWithoutProfileActivity.f18726b0;
            if (e2Var != null) {
                e2Var.f21492s.m4595d(InfoType.SMART_ERROR, new View$OnClickListenerC0050b(userWorkWithoutProfileActivity, 9));
                return Unit.f29503a;
            }
            MutabilityOwnership.m3737u("binding");
            throw null;
        }
    }

    /* compiled from: UserWorkWithoutProfileActivity.kt */
    /* renamed from: jp.pxv.android.activity.UserWorkWithoutProfileActivity$b */
    /* loaded from: classes2.dex */
    public static final class C4141b extends Lambda implements AbstractC3446l<PixivResponse, Unit> {

        /* renamed from: b */
        public final /* synthetic */ long f18734b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4141b(long j) {
            super(1);
            UserWorkWithoutProfileActivity.this = r1;
            this.f18734b = j;
        }

        @Override // p189gn.AbstractC3446l
        public Unit invoke(PixivResponse pixivResponse) {
            UserWorkWithoutProfileActivity userWorkWithoutProfileActivity = UserWorkWithoutProfileActivity.this;
            long j = this.f18734b;
            PixivProfile pixivProfile = pixivResponse.profile;
            MutabilityOwnership.m3746l(pixivProfile, "pixivResponse.profile");
            WorkType workType = UserWorkWithoutProfileActivity.this.f18727c0;
            if (workType != null) {
                ActivityUserWorkWithoutProfileBinding e2Var = userWorkWithoutProfileActivity.f18726b0;
                if (e2Var != null) {
                    e2Var.f21492s.m4598a();
                    BackStackRecord cVar = new BackStackRecord(userWorkWithoutProfileActivity.m11131K0());
                    cVar.m11165j(R.id.user_work_list_container, UserWorkFragment.m1700B(j, pixivProfile, workType));
                    cVar.mo11171d();
                    return Unit.f29503a;
                }
                MutabilityOwnership.m3737u("binding");
                throw null;
            }
            MutabilityOwnership.m3737u("workType");
            throw null;
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.UserWorkWithoutProfileActivity$c */
    /* loaded from: classes2.dex */
    public static final class C4142c extends Lambda implements AbstractC3435a<PixivSettings> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18735a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4142c(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18735a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [ai.b, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final PixivSettings invoke() {
            return C1124a.m10173s(this.f18735a).f24118a.m920a().m621a(Reflection.m5499a(PixivSettings.class), null, null);
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.UserWorkWithoutProfileActivity$d */
    /* loaded from: classes2.dex */
    public static final class C4143d extends Lambda implements AbstractC3435a<UserProfileService> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18736a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4143d(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18736a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [im.a, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final UserProfileService invoke() {
            return C1124a.m10173s(this.f18736a).f24118a.m920a().m621a(Reflection.m5499a(UserProfileService.class), null, null);
        }
    }

    /* renamed from: e1 */
    public final void m4685e1(long j) {
        ActivityUserWorkWithoutProfileBinding e2Var = this.f18726b0;
        if (e2Var != null) {
            e2Var.f21492s.m4595d(InfoType.LOADING, null);
            UserProfileRepository aVar = ((UserProfileService) this.f18730f0.getValue()).f17525a;
            Single<String> a = aVar.f22598a.mo1127a();
            C7463r rVar = new C7463r(aVar, j, 3);
            Objects.requireNonNull(a);
            Disposable e = subscribers.m2591e(new SingleFlatMap(a, rVar).m961o(C6034a.f26178c).m966j(AndroidSchedulers.m334a()), new C4140a(), new C4141b(j));
            CompositeDisposable aVar2 = this.f18731g0;
            MutabilityOwnership.m3744n(aVar2, "compositeDisposable");
            aVar2.mo82c(e);
            return;
        }
        MutabilityOwnership.m3737u("binding");
        throw null;
    }

    @Override // p270jp.pxv.android.activity.AbstractActivityC4151b, p270jp.pxv.android.activity.BaseActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        WorkType workType;
        super.onCreate(bundle);
        ViewDataBinding d = DataBindingUtil.m11369d(this, R.layout.activity_user_work_without_profile);
        MutabilityOwnership.m3746l(d, "setContentView(this, R.l…ser_work_without_profile)");
        ActivityUserWorkWithoutProfileBinding e2Var = (ActivityUserWorkWithoutProfileBinding) d;
        this.f18726b0 = e2Var;
        MaterialToolbar materialToolbar = e2Var.f21493t;
        MutabilityOwnership.m3746l(materialToolbar, "binding.toolBar");
        C0536v1.m11537h(this, materialToolbar, R.string.user_works);
        PixivAnalytics eVar = this.f18757A;
        MutabilityOwnership.m3746l(eVar, "pixivAnalytics");
        eVar.m6524f(AnalyticsScreenName.USER_WORK, null);
        this.f18728d0 = getIntent().getLongExtra("USER_ID", 0);
        if (bundle != null) {
            Serializable serializable = bundle.getSerializable("WORK_TYPE");
            Objects.requireNonNull(serializable, "null cannot be cast to non-null type jp.pxv.android.commonObjects.model.WorkType");
            workType = (WorkType) serializable;
        } else {
            Serializable serializableExtra = getIntent().getSerializableExtra("WORK_TYPE");
            Objects.requireNonNull(serializableExtra, "null cannot be cast to non-null type jp.pxv.android.commonObjects.model.WorkType");
            workType = (WorkType) serializableExtra;
        }
        this.f18727c0 = workType;
        PixivSettings bVar = (PixivSettings) this.f18729e0.getValue();
        WorkType workType2 = this.f18727c0;
        if (workType2 != null) {
            bVar.m12121g(workType2);
            m4685e1(this.f18728d0);
            return;
        }
        MutabilityOwnership.m3737u("workType");
        throw null;
    }

    @Override // p014ae.AdActivity, p270jp.pxv.android.activity.BaseActivity, p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        this.f18731g0.m80f();
        super.onDestroy();
    }

    @Subscribe
    public final void onEvent(SelectWorkTypeEvent selectWorkTypeEvent) {
        MutabilityOwnership.m3745m(selectWorkTypeEvent, "event");
        WorkType workType = selectWorkTypeEvent.getWorkType();
        MutabilityOwnership.m3746l(workType, "event.workType");
        this.f18727c0 = workType;
    }

    @Override // androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onSaveInstanceState(Bundle bundle) {
        MutabilityOwnership.m3745m(bundle, "outState");
        WorkType workType = this.f18727c0;
        if (workType != null) {
            bundle.putSerializable("WORK_TYPE", workType);
            super.onSaveInstanceState(bundle);
            return;
        }
        MutabilityOwnership.m3737u("workType");
        throw null;
    }
}
